home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 2
/
AACD 2.iso
/
AACD
/
WebSites
/
Sites
/
Wirenet
/
files
/
AutoNotify.lha
/
SendMail.br
< prev
Wrap
Text File
|
1999-02-06
|
2KB
|
83 lines
/*
$VER: Sendmail 2.0 (17.12.98) Neil Bothwick
A Thor script to create a Thor email event
*/
/* ;;; Initialise */
options results
if ~show('p', 'BBSREAD') then do
address command
'run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead'
'WaitForPort BBSREAD'
'WaitForPort BBSREAD'
end
;;;
/* ;;; Read arguments */
parse arg arguments
template = 'SYSTEM/A,CONF/A,ADDRESS/A,NAME/K,SUBJECT/K,TEXT/K,CC/K,BCC/K,ATTACH/K'
drop ARGS.
ARGS.SUBJECT= ' '
ARGS.TEXT = 'STDIN'
address(BBSREAD)
READARGS template ARGS CMDLINE arguments
if RC = 5 then call ExitMsg('Usage: SendMail.br' template)
;;;
/* ;;; Create message file */
address(BBSREAD)
drop SysInfo.
GETBBSDATA bbsname '"'ARGS.SYSTEM'"' stem SysInfo
UNIQUEMSGFILE bbsname '"'ARGS.SYSTEM'"' stem MsgFile
if ~open(out,MsgFile.NAME,'w') then call ExitMsg('Unable to create message file')
if symbol('ARGS.CC') = VAR then call writeln(out,'cc:' ARGS.CC)
if symbol('ARGS.BCC') = VAR then call writeln(out,'bcc:' ARGS.BCC)
/* Add contents of .header */
if exists(SysInfo.BBSPATH||'.header') then do
if ~open(hdr,SysInfo.BBSPATH||'.header','r') then call ExitMsg('Could not open header file')
do until eof(hdr)
call writeln(out,readln(hdr))
end
call close(hdr)
end
else if symbol('ARGS.CC') = VAR | symbol('ARGS.BCC') = VAR then call writeln(out,'')
/* Copy from text to message file */
if ARGS.TEXT = 'STDIN' then do
do until eof('STDIN')
call writeln(out,compress(readln('STDIN'),'0d'x)) /* Strip superfluous CRs */
end
end
else do
if ~open(text,ARGS.TEXT,'R') then call ExitMsg('Could not read message text file')
do until eof(text)
call writeln(out,compress(readln(text),'0d'x)) /* Strip superfluous CRs */
end
call close(text)
end
call close(out)
;;;
/* ;;; Create email event */
drop EventData.
EventData.TOADDR = ARGS.ADDRESS
EventData.SUBJECT = ARGS.SUBJECT
EventData.CONFERENCE = ARGS.CONF
EventData.MSGFILE = MsgFile.FILEPART
if symbol('ARGS.NAME') = VAR then EventData.TONAME = ARGS.NAME
if symbol('ARGS.ATTACH') = VAR then EventData.LOCALFILE = ARGS.ATTACH
WRITEBREVENT bbsname '"'ARGS.SYSTEM'"' event 0 stem EventData
if(rc ~= 0) then call ExitMsg(BBSREAD.LASTERROR)
;;;
exit
ExitMsg:
parse arg msg
if msg > '' then do
say;say msg;say
exit 5
else exit
return